#ifndef AUTO_TOP_H
#define AUTO_TOP_H

#include <avr/pgmspace.h>
#include "WProgram.h"

#include <LiquidCrystal.h>
#include <EEPROM.h>

#include "Clock.h";
#include "Aquarium_Modes.h"
#include "utility.h";

const int Auto_Top_Pin_OUT = 34;
const int Auto_Top_Pin_IN = 35;
//const int Auto_Top_device_num = 11;
class Auto_Top
{

public:

  void init();
  void Save_To_EEPROM();
  void update(bool new_day);
  void Clear_Errors();

  byte Get_Number_Of_Print_Errors();
  void Print_Error(byte Line);

  int Get_Max_On_Time() { 
    return Max_On_Time;
  }
  void Set_Max_On_Time(int _Max_On_Time) { 
    Max_On_Time = _Max_On_Time;
  }

  byte Get_Max_Number_Of_Time_In_Day(){
    return Max_Number_Of_Time_In_Day;
  }

  void Set_Max_Number_Of_Time_In_Day( byte _Max_Number_Of_Time_In_Day){
    Max_Number_Of_Time_In_Day = _Max_Number_Of_Time_In_Day;
  }

  void Set_OnOff( bool _OnOff){
    OnOff = _OnOff;
  }
  
  byte Get_OnOff(){
    return OnOff;
  }
  
  
  void Set_Modes( byte _Modes){
    Modes = _Modes;
  }
  
  byte Get_Modes(){
    return Modes;
  }
  
  byte Get_Number_Of_Time_Pump_On_Today(){
    return Number_Of_Time_Pump_On_Today;
  }
  
  bool Is_There_Error(){
    return   (Max_Pump_Time_Error |  Max_Number_Of_Time_In_Day_Error |  Pump_Did_Not_Turn_Today_Error);
  }

  bool Is_Pump_On();

private:  
  void Turn_Pump_Off();
  void Turn_Pump_On();
  void Turn_Pump_On_Off();
  
  bool Check_Modes(byte Mode);

  bool OnOff;
  int    Max_On_Time; // in sec
  byte Max_Number_Of_Time_In_Day;
  byte Modes;

  bool pump_status;
  byte cur_mode;
  
  unsigned long Last_time_On;
  bool Is_Pump_on_Today;
  byte pump_on_min;
  byte Number_Of_Time_Pump_On_Today;

  bool Max_Pump_Time_Error;
  bool Max_Number_Of_Time_In_Day_Error;
  bool Pump_Did_Not_Turn_Today_Error;


};


#endif










